import java.util.Scanner;

public class Login {
    //实现一个简单的控制台版用户登陆程序, 程序启动提示用户输入用户名密码. 如果用户名密码出错, 使用自定义异常的方式来处理
    private String username = "admin";
    private String password = "123456";

    public  void verify(String username,String password){
        if(this.username.equals(username) == false){
            throw new PasswordException("用户名错误");
        }
        if(this.password.equals(password) == false){
            throw new PasswordException("密码错误");
        }
        System.out.println("登录成功！");
    }

    public static void main(String[] args) {
        Login login = new Login();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String username = scanner.nextLine();
        System.out.println("请输入密码");
        String password = scanner.nextLine();
        login.verify(username, password);
    }
}
